<?php

namespace app\mall\controller\api\uc\store;

use app\mall\enum\StatusEnum;
use app\mall\exceptions\ApiException;
use app\mall\model\MallStoreClerk;

class Clerk extends Base
{

    /**
     * @return \think\response\Json
     * @throws \app\mall\exceptions\BaseException
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function index()
    {
        $id = $this->request->get('id');
        if (!intval($id)) {
            ApiException::throws(ApiException::$requireArgs);
        }
        $model = MallStoreClerk::where('status', StatusEnum::VALID)
            ->field(['id', 'name', 'avatar', 'slogan']);
        $info = $model->find($id);
        if (!$info) {
            ApiException::throws(ApiException::$infoNotFound);
        }
        return json_return($info);
    }

}